{% load i18n %}
{% load lfs_tags %}

<table class="lfs-manage-table">
    <tr>
        <th colspan="2">
            {% trans 'General' %}
        </th>
    </tr>
    <tr>
        <td class="label"
            style="width:150px">
            {% trans 'ID' %}:
        </td>
        <td>
            {{ cart.id }}
        </td>
    </tr>
    <tr>
        <td class="label">
            {% trans 'Customer' %}:
        </td>
        <td>
			{% if customer.selected_invoice_address %}
				<div>
					{{ customer.selected_invoice_address.firstname }}
					{{ customer.selected_invoice_address.lastname }}
					(<a href="mailto:{{ customer.selected_invoice_address.email }}">{{ customer.selected_invoice_address.email }}</a>)
				</div>
				<div>
					{{ customer.selected_invoice_address.company_name }}
				</div>
				<div>
					{{ customer.selected_invoice_address.street }}
				</div>
				<div>
					{{ customer.selected_invoice_address.city }}
				</div>
				<div>
					{{ customer.selected_invoice_address.state }}
				</div>
				<div>
					{{ customer.selected_invoice_address.zip_code }}
				</div>
				<div>
					{{ customer.selected_invoice_address.country }}
				</div>
				<div>
					{{ customer.selected_invoice_address.phone }}
				</div>
			{% else %}
				---
			{% endif %}
        </td>
    </tr>
    <tr>
        <td class="label">
            {% trans 'Creation date' %}:
        </td>
        <td>
            {{ cart.creation_date|date:_("DATETIME_FORMAT") }}
        </td>
    </tr>
    <tr>
        <td class="label">
            {% trans 'Modification date' %}:
        </td>
        <td>
            {{ cart.modification_date|date:_("DATETIME_FORMAT") }}
        </td>
    </tr>
    <tr>
        <td class="label">
            {% trans 'Items' %}:
        </td>
        <td>
            {{ cart.get_amount_of_items }}
        </td>
    </tr>
    <tr>
        <td class="label">
            {% trans 'Total' %}:
        </td>
        <td>
            {{ total|currency:request }}
        </td>
    </tr>
</table>

{% if cart.get_items %}
    <table class="lfs-manage-table">
        <tr>
            <th class="small">
                {% trans 'ID' %}
            </th>
            <th class="middle">
                {% trans 'Creation date' %}
            </th>
            <th>
                {% trans 'Product' %}
            </th>
            <th class="number middle">
                {% trans 'Price' %}
            </th>
            <th class="number middle">
                {% trans 'Amount' %}
            </th>
            <th class="number middle">
                {% trans 'Total' %}
            </th>
        </tr>
        {% for item in cart.get_items %}
            <tr class="clickable"
                onclick="window.location='{% url lfs_manage_product item.product.id %}'">
                <td class="small-right">
                	{{ item.id }}
                </td>
                <td>
					{{ item.creation_date|date:_("DATETIME_FORMAT") }}
			    </td>
                <td>
                	{{ item.product.get_name }}
                    {% for property in item.product.get_variant_properties %}
                        <div>
                            {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                        </div>
                    {% endfor %}

                    {% for property in item.product.get_displayed_properties %}
                        <div>
                            {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                        </div>
                    {% endfor %}

                    {% if item.product.is_configurable_product %}
                        {% for property in item.get_properties %}
                            <div>
                                {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                                {% if property.obj.is_select_field and property.display_price %}
                                    ({{ property.price|currency:request }})
                                {% endif %}
                            </div>
                        {% endfor %}
                    {% endif %}
                </td>
                <td class="number">
                    {{ item|get_price:request|currency:request }}
                </td>
                <td class="number">
                    {{ item.amount }}
                </td>
                <td class="number">
                    {{ item|get_price_gross:request|currency:request }}
                </td>
            </tr>
        {% endfor %}
    </table>
{% else %}
    {% trans 'This cart has no items' %}
{% endif %}
